/*
 * Copyright (C) 2023-2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * Description: Cast engine related common data stucture definitions.
 * Author: zhangge
 * Create: 2022-06-15
 */

#ifndef CAST_ENGINE_COMMON_H
#define CAST_ENGINE_COMMON_H

#include <array>
#include <map>
#include <string>

#include <message_parcel.h>
#define EXPORT __attribute__((visibility("default")))

namespace OHOS {
namespace CastEngine {

enum class EXPORT EventId {
    EVENT_BEGIN = 1,
    STREAM_BEGIN = 2000,
    STEAM_DEVICE_DISCONNECTED,
    STREAM_END = 2999,
    EVENT_END = 5000,
};

inline bool EXPORT IsEventId(int32_t state)
{
    return (state > static_cast<int32_t>(EventId::EVENT_BEGIN)) && (state < static_cast<int32_t>(EventId::EVENT_END));
}

struct EXPORT MediaInfo {
    std::string mediaId;
    std::string mediaName;
    std::string mediaUrl;
    std::string mediaType;
    size_t mediaSize;
    uint32_t startPosition;
    uint32_t duration;
    uint32_t closingCreditsPosition;
    std::string albumCoverUrl;
    std::string albumTitle;
    std::string mediaArtist;
    std::string lrcUrl;
    std::string lrcContent;
    std::string appIconUrl;
    std::string appName;
};

struct EXPORT MediaInfoHolder {
    uint32_t currentIndex;
    std::vector<MediaInfo> mediaInfoList;
    uint32_t progressRefreshInterval;
};

enum class EXPORT DmrStates {
    DMR_STATE_UNAVAILABLE = 0,
    DMR_STATE_AVAILABLE = 1,
    DMR_STATE_BUTT = 2,
};

enum class EXPORT PlayerStates {
    PLAYER_STATE_ERROR = 0,
    PLAYER_IDLE = 1,
    PLAYER_INITIALIZED = 2,
    PLAYER_PREPARING = 3,
    PLAYER_PREPARED = 4,
    PLAYER_STARTED = 5,
    PLAYER_PAUSED = 6,
    PLAYER_STOPPED = 7,
    PLAYER_PLAYBACK_COMPLETE = 8,
    PLAYER_RELEASED = 9,
    PLAYER_BUFFERING = 100,
};

enum class EXPORT LoopMode {
    LOOP_MODE_SEQUENCE = 0,
    LOOP_MODE_SINGLE = 1,
    LOOP_MODE_LIST = 2,
    LOOP_MODE_SHUFFLE = 3
};

enum class EXPORT PlaybackSpeed {
    SPEED_FORWARD_0_75_X = 0,
    SPEED_FORWARD_1_00_X = 1,
    SPEED_FORWARD_1_25_X = 2,
    SPEED_FORWARD_1_75_X = 3,
    SPEED_FORWARD_2_00_X = 4
};

inline constexpr int EXPORT INVALID_ID = -1;
inline constexpr int EXPORT INVALID_VALUE = -1;
inline constexpr int EXPORT DECIMALISM = 10;
const std::string DLNA_SURFACE_NAME = "dlna_window";
const std::string DLNA_APP_BUNDLE_NAME = "com.example.dlnaplayer";
const std::string DLNA_APP_ABILITY_NAME = "EntryAbility";

const std::string DLNA_GALLERY_APP_BUNDLE_NAME = "com.samples.album";
const std::string DLNA_GALLERY_APP_ABILITY_NAME = "MainAbility";
const int DLNA_PLAYER_EVENT = 100;

} // namespace CastEngine
} // namespace OHOS

#endif
